/*
 * Copyright (c) Shenzhen 7th Road Technical Co., Ltd
 * Technical Support dept.
 * http://www.7road.com
 */
package com.sz7thrd.ts.core.utils.concurrent;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author able
 * @date 2011-11-9
 * ===============================
 * 
 * 
 */
//public class ExecuteWrapper implements Runnable {
//
//	private static final Logger log = LoggerFactory.getLogger(ExecuteWrapper.class);
//	private final Runnable runnable;
//
//	public ExecuteWrapper(Runnable runnable) {
//		this.runnable = runnable;
//	}
//
//	@Override
//	public final void run() {
//		ExecuteWrapper.execute(runnable, getMaximumRuntimeInMillisecWithoutWarning());
//	}
//
//	protected long getMaximumRuntimeInMillisecWithoutWarning() {
//		return Long.MAX_VALUE;
//	}
//
//	public static void execute(Runnable runnable) {
//		execute(runnable, Long.MAX_VALUE);
//	}
//
//	public static void execute(Runnable runnable, long maximumRuntimeInMillisecWithoutWarning) {
//		long begin = System.nanoTime();
//
//		try {
//			runnable.run();
//		} catch (RuntimeException e) {
//			log.warn("Exception in a Runnable execution:", e);
//		} finally {
//			long runtimeInNanosec = System.nanoTime() - begin;
//			Class<? extends Runnable> clazz = runnable.getClass();
//
//			RunnableStatsManager.handleStats(clazz, runtimeInNanosec);
//
//			long runtimeInMillisec = TimeUnit.NANOSECONDS.toMillis(runtimeInNanosec);
//
//			if (runtimeInMillisec > maximumRuntimeInMillisecWithoutWarning) {
//				TextBuilder tb = TextBuilder.newInstance();
//
//				tb.append(clazz);
//				tb.append(" - execution time: ");
//				tb.append(runtimeInMillisec);
//				tb.append("msec");
//
//				log.warn(tb.toString());
//
//				TextBuilder.recycle(tb);
//			}
//		}
//	}
//}
